#!/usr/bin/env python3
# coding: utf-8

from pylab import *


def x(t):
    return 5 - 0.75 * t

def y(t):
    return t - 2

def d(p1, p2):
    return sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2)

def main(p):
    distance = [[], []]
    line = [[], []]
    for t in arange(-5, 15, 0.01):
        line[0].append(x(t))
        line[1].append(y(t))
        distance[0].append(t)
        distance[1].append(d(p, [x(t), y(t)]))
    plot(p[0], p[1], marker='o', color='blue')
    plot(line[0], line[1], linewidth=0.5, color='#0000AA')
    plot(distance[0], distance[1], color='red', linewidth=0.25, marker=',')

if __name__ == "__main__":
    main([0, 0])
    main([2.5, 0])
    main([3.45, 0])
    grid()
    show()
